package com.greenold.checkInConfig.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.greenold.common.annotation.Log;
import com.greenold.common.core.controller.BaseController;
import com.greenold.common.core.domain.AjaxResult;
import com.greenold.common.enums.BusinessType;
import com.greenold.checkInConfig.domain.CheckinConfig;
import com.greenold.checkInConfig.service.ICheckinConfigService;
import com.greenold.common.utils.poi.ExcelUtil;
import com.greenold.common.core.page.TableDataInfo;

/**
 * 入住配置Controller
 * 
 * @author ruoyi
 * @date 2025-10-19
 */
@RestController
@RequestMapping("/checkInConfig/config")
public class CheckinConfigController extends BaseController
{
    @Autowired
    private ICheckinConfigService checkinConfigService;

    /**
     * 查询入住配置列表
     */
    @PreAuthorize("@ss.hasPermi('checkInConfig:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckinConfig checkinConfig)
    {
        startPage();
        List<CheckinConfig> list = checkinConfigService.selectCheckinConfigList(checkinConfig);
        return getDataTable(list);
    }

    /**
     * 导出入住配置列表
     */
    @PreAuthorize("@ss.hasPermi('checkInConfig:config:export')")
    @Log(title = "入住配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckinConfig checkinConfig)
    {
        List<CheckinConfig> list = checkinConfigService.selectCheckinConfigList(checkinConfig);
        ExcelUtil<CheckinConfig> util = new ExcelUtil<CheckinConfig>(CheckinConfig.class);
        util.exportExcel(response, list, "入住配置数据");
    }

    /**
     * 获取入住配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('checkInConfig:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(checkinConfigService.selectCheckinConfigById(id));
    }

    /**
     * 新增入住配置
     */
    @PreAuthorize("@ss.hasPermi('checkInConfig:config:add')")
    @Log(title = "入住配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckinConfig checkinConfig)
    {
        return toAjax(checkinConfigService.insertCheckinConfig(checkinConfig));
    }

    /**
     * 修改入住配置
     */
    @PreAuthorize("@ss.hasPermi('checkInConfig:config:edit')")
    @Log(title = "入住配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckinConfig checkinConfig)
    {
        return toAjax(checkinConfigService.updateCheckinConfig(checkinConfig));
    }

    /**
     * 删除入住配置
     */
    @PreAuthorize("@ss.hasPermi('checkInConfig:config:remove')")
    @Log(title = "入住配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(checkinConfigService.deleteCheckinConfigByIds(ids));
    }
}
